package com.ujs.edu.demo.dao;

import com.ujs.edu.demo.dataobject.BcNews;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface BcNewsMapper {
    @Delete({
        "delete from bc_news",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into bc_news (id, title, ",
        "newhref, categoryId, ",
        "createTime, content)",
        "values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, ",
        "#{newhref,jdbcType=VARCHAR}, #{categoryid,jdbcType=INTEGER}, ",
        "#{createtime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR})"
    })
    int insert(BcNews record);

    @Select({
        "select",
        "id, title, newhref, categoryId, createTime, content",
        "from bc_news",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="newhref", property="newhref", jdbcType=JdbcType.VARCHAR),
        @Result(column="categoryId", property="categoryid", jdbcType=JdbcType.INTEGER),
        @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    BcNews selectByPrimaryKey(Integer id);

    @Select({
        "select",
        "id, title, newhref, categoryId, createTime, content",
        "from bc_news"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="newhref", property="newhref", jdbcType=JdbcType.VARCHAR),
        @Result(column="categoryId", property="categoryid", jdbcType=JdbcType.INTEGER),
        @Result(column="createTime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<BcNews> selectAll();

    @Update({
        "update bc_news",
        "set title = #{title,jdbcType=VARCHAR},",
          "newhref = #{newhref,jdbcType=VARCHAR},",
          "categoryId = #{categoryid,jdbcType=INTEGER},",
          "createTime = #{createtime,jdbcType=TIMESTAMP},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BcNews record);
}